<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('RGV执行队列列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>查询类型：</label>
                                <select name="jdbz" th:with="type=${@dict.getType('radio_type')}">
                                    <!--                                <option value="">所有</option>-->
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <label>任务号：</label>
                                <input type="text" name="taskNo"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search('formId','bootstrap-table')"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset('formId','bootstrap-table')"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">

                <a class="btn btn-primary multiple disabled" onclick="reloadTask()" shiro:hasPermission="device:rgvqueue:edit">
                    <i class="fa fa-edit"></i>&nbsp;重新下发</a>

                <a class="btn btn-danger multiple disabled" onclick="deleteTask()" shiro:hasPermission="device:rgvqueue:remove">
                    <i class="fa fa-remove"></i>&nbsp;删除</a>

            </div>
            <div class="col-sm-12 select-table table-bordered">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('device:rgvqueue:edit')}]];
        var removeFlag = [[${@permission.hasPermi('device:rgvqueue:remove')}]];
        var xfDatas = [[${@dict.getType('task_xf')}]];
        var rwlxDatas = [[${@dict.getType('dev_type')}]];
        var mlfsDatas = [[${@dict.getType('dev_mlfs')}]];
        var prefix = ctx + "device/rgvqueue";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                reloadTaskUrl: prefix + "/reloadTask",
                deleteTaskUrl: prefix + "/deleteTask",
                modalName: "RGV执行队列",
                clickToSelect: true,//是否启用点击选中行
                uniqueId:"taskNo",//表主键(用于修改和删除)
                columns: [
                    {
                        halign: 'center',
                        align:'center',
                        checkbox: true
                    },
                {
                    title: "序号",
                    halign: 'center',
                    align:'center',
                    width: 55,
                    formatter:function (value, row, index) {
                        //获取每页显示的数量
                        var pageSize = $('#bootstrap-table').bootstrapTable('getOptions').pageSize;
                        //获取当前是第几页
                        var pageNumber = $('#bootstrap-table').bootstrapTable('getOptions').pageNumber;
                        //返回序号，注意index是从0开始的，所以要加上1
                        return pageSize * (pageNumber - 1) + index + 1;

                    }
                },
                {
                    field: 'devId',
                    title: '设备编号',
                    halign: 'center',
                    align:'center',
                    sortable: true,
                    visible: true
                },
                {
                    field: 'devName',
                    title: '设备名称',
                    halign: 'center',
                    align:'center',
                    sortable: true,
                    visible: true
                },
                {
                    field: 'taskNo',
                    title: '任务号',
                    halign: 'center',
                    align:'center',
                    sortable: true,
                    visible: true
                },

                {
                    field: 'yp',
                    title: '源排',
                    halign: 'center',
                    align:'center',
                    sortable: true,
                    visible: true
                },
                {
                    field: 'yl',
                    title: '源列',
                    halign: 'center',
                    align:'center',
                    sortable: true,
                    visible: true
                },
                {
                    field: 'mbp',
                    title: '目标排',
                    halign: 'center',
                    align:'center',
                    sortable: true,
                    visible: true
                },
                {
                    field: 'mbl',
                    title: '目标列',
                    halign: 'center',
                    align:'center',
                    sortable: true,
                    visible: true
                },
                {
                    field: 'status',
                    title: '是否下发',
                    halign: 'center',
                    align:'center',
                    sortable: true,
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(xfDatas, value);
                    }
                },

                {
                    field: 'create_time',
                    title: '创建时间',
                    halign: 'center',
                    align:'center',
                    sortable: true,
                    visible: true
                },
                {
                    field: 'finish_time',
                    title: '完成时间',
                    halign: 'center',
                    align:'center',
                    sortable: true,
                    visible: true
                },
                {
                    field: 'type',
                    title: '设备名称',
                    halign: 'center',
                    align:'center',
                    sortable: true
                }
                // ,
                // {
                //     title: '操作',
                //     halign: 'center',
                //     align: 'center',
                //     formatter: function(value, row, index) {
                //         var actions = [];
                //         actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.rwh + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                //         actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.rwh + '\')"><i class="fa fa-remove"></i>删除</a>');
                //         return actions.join('');
                //     }
                // }
                ]
            };
            $.table.init(options);
        });
        function reloadTask() {
            table.set();
            var rows = $.common.isEmpty(table.options.uniqueId) ? $.table.selectFirstColumns() : $.table.selectColumns(table.options.uniqueId);
            if (rows.length == 0) {
                $.modal.alertWarning("请至少选择一条记录！");
                return;
            }
            if (rows.length > 1) {
                $.modal.alertWarning("只允许选择一条记录！");
                return;
            }

            $.modal.confirm("确认要重新下发选中的" + rows.length + "条任务吗?", function () {
                var url = table.options.reloadTaskUrl;
                var data = {"taskNo": rows.join()};
                $.operate.submit(url, "post", "json", data);
            });
        }
        function deleteTask() {
            table.set();
            var rows = $.common.isEmpty(table.options.uniqueId) ? $.table.selectFirstColumns() : $.table.selectColumns(table.options.uniqueId);
            if (rows.length == 0) {
                $.modal.alertWarning("请至少选择一条记录！");
                return;
            }
            if (rows.length > 1) {
                $.modal.alertWarning("只允许选择一条记录！");
                return;
            }
            $.modal.confirm("确认要删除选中的" + rows.length + "条任务吗?", function () {
                var url = table.options.deleteTaskUrl;
                var data = {"taskNo": rows.join()};
                $.operate.submit(url, "post", "json", data);
            });
        }
    </script>
</body>
</html>